#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include "ui_widget.h"
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QDebug>
#include <QTimer>
#include <QListView>
#include <QMessageBox>
#include <QTime>
#include <QPlainTextEdit>
#include <QDir>
#include <QFileDialog>
#include <QTextCodec>
#include <QMimeDatabase>
#include <QTextStream>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE



class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_SerialPortSwitch_Bt_clicked2();



    void on_ComFlush_BT_clicked2();
    void FindSerialPort();
    void SerialPortReadyRead_slot();
    void on_ClearRx_Bt_clicked2();
    void on_ClearTx_Bt_clicked2();
    void on_Send_Bt_clicked2();
    void SerialSendData(QByteArray baData);
    void on_TimeSend_checkBox_stateChanged2(int arg1);
    void on_SelectFile_Bt_clicked2();
    void SendFile();
    void File_TimerSend();



private:
    Ui::Widget *ui;
    QStringList serialDevice;
    QSerialPort *serial;
    struct{
       bool isSerialOpen;
       bool isSendFile;

    } global_struct;
    qint64 FrameCount;
    double ProgressBarValue;
    qint64 dataTotalRxCnt;
//    qint64 dataTotalTxCnt;
    QString SendTextEditStr;
    QByteArray SendTextEditBa;
    qint64 serialDataTotalTxCnt;
    qint64 FrameLen;
    qint64 FrameGap;
    double FrameNumber;
    qint64 LastFrameLen;
    double ProgressBarStep;

    QTimer * TimerSend;
    QTimer * FileSendTimer;
    QString FileText;
    QByteArray data;
};
#endif // WIDGET_H
